package marmalius;
/*
	gestion des drops des npcs
	creer par Metos [EOAH]
*/

public class NpcDrop {
	
	private static final int maxNpcDrop = 3800;
	private static final int maxDrop = 20; //20 item par npc
	
	private int [][] item = new int[maxNpcDrop][maxDrop];
	private int [][] nbItem = new int[maxNpcDrop][maxDrop];
	private int [][] hopeDrop = new int[maxNpcDrop][maxDrop];

	public NpcDrop() {
		for (int a = 0; a < maxNpcDrop; a++) {
			for (int i = 0; i < maxDrop; i++) {
				item[a][i] = -1;
				nbItem[a][i] = -1;
				hopeDrop[a][i] = -1;
			}
		}
	}
	
	public boolean addDrop(int nnpcId, int nitem, int nnbItem, int nHope) { //return false s'il n'a pas pu rajoute le drop
		if (nnpcId >= maxNpcDrop) {
			return false;
		}
		for (int i = 0; i < maxDrop; i++) {
			if (item[nnpcId][i] == -1) {
				item[nnpcId][i] = nitem;
				nbItem[nnpcId][i] = nnbItem;
				hopeDrop[nnpcId][i] = nHope;
				return true;
			}
		}
		return false;
	}
	
	public int maxFindDrop(int npcId) {
		for (int i = 0; i < maxDrop; i++) {
			if (item[npcId][i] == -1) {
				return i - 1;
			}
		}
		return maxDrop - 1;
	}
	
	public int rItem(int nnpcId, int ni) {
		return item[nnpcId][ni];
	}
	
	public int rNbItem(int nnpcId, int ni) {
		return nbItem[nnpcId][ni];
	}
	
	public int rHopeDrop(int nnpcId, int ni) {
		return hopeDrop[nnpcId][ni];
	}
}
